package cn.com.JFinal;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;
import com.jfinal.upload.UploadFile;

import cn.com.Controller.HelloController;
import cn.com.Controller.UploadController;
import cn.com.Controller.UserController;
import cn.com.bean.User;
import freemarker.cache.MruCacheStorage;

/**
 * <p>
 * Title: DemoConfig
 * </p>
 * <p>
 * Description:
 * </p>
 * 
 * @author WangJun
 * @date 2018年9月15日 上午10:34:55
 */
public class DemoConfig extends JFinalConfig {
	public void configConstant(Constants me) {
//		me.setFileRenderPath("/file");
		me.setUploadedFileSaveDirectory("file");
		me.setDevMode(true);
		me.setViewType(ViewType.FREE_MARKER);
	}

	public void configRoute(Routes me) {
		// 第一次使用use加载的配置将成为主配置，可以通过PropKit.get(...)直接取值
//		PropKit.use("a_little_config.txt");
		me.add("/hello", HelloController.class);
		me.add("/user", UserController.class);
		me.add("/files", UploadController.class);
	}

	public void configPlugin(Plugins me) {
		loadPropertyFile("db.properties");
		C3p0Plugin c3p0Plugin = new C3p0Plugin(getProperty("url"), getProperty("username"), getProperty("password"));
		me.add(c3p0Plugin);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		arp.addMapping("user", User.class);
	}

	public void configInterceptor(Interceptors me) {
	}

	public void configHandler(Handlers me) {

	}
}
